package gui;

import guiCode.PrevSemesterCode;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Color;
import java.awt.GridBagLayout;
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.Rectangle;
import java.awt.Font;

import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JTextArea;
import javax.swing.JList;
import javax.swing.JTextPane;
import javax.swing.JScrollPane;
import javax.swing.JTextField;

public class PrevSemestersGUI extends JPanel{
	SpringLayout springLayout;
	private JPanel panel;
	SpringLayout sl_panel;
	JLabel label ;
	JLabel label_1;
	JLabel label_2;
	JButton btnNext;
	JButton btnMainMenu;
	private static JComboBox comboBox;
	private JLabel lblSemesterOrBy;
	PrevSemesterCode psc;
	JLabel lblNot;
	
	public PrevSemestersGUI() {
		super();
		initialize();
	}
	private void initialize() {
		this.setSize(900,600);
		this.setBackground(UIManager.getColor("InternalFrame.activeTitleBackground"));
		//this.setLayout(null);
		springLayout = new SpringLayout();
		setLayout(springLayout);
		
		panel = new JPanel();
		springLayout.putConstraint(SpringLayout.SOUTH, panel, 492, SpringLayout.NORTH, this);
		panel.setBackground(UIManager.getColor("InternalFrame.activeTitleBackground"));
		springLayout.putConstraint(SpringLayout.EAST, panel, 839, SpringLayout.WEST, this);
		panel.setSize(900, 600);
		springLayout.putConstraint(SpringLayout.NORTH, panel, 44, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.WEST, panel, 43, SpringLayout.WEST, this);
		add(panel);
		sl_panel = new SpringLayout();
		panel.setLayout(sl_panel);
		
		label_1 = new JLabel("semester name and course");
		sl_panel.putConstraint(SpringLayout.WEST, label_1, 386, SpringLayout.WEST, panel);
		label_1.setFont(new Font("Tahoma", Font.BOLD, 13));
		panel.add(label_1);
		
		btnNext = new JButton("next");
		btnNext.setFont(new Font("Tahoma", Font.BOLD, 14));
		sl_panel.putConstraint(SpringLayout.EAST, btnNext, -327, SpringLayout.EAST, panel);
		sl_panel.putConstraint(SpringLayout.SOUTH, btnNext, -63, SpringLayout.SOUTH, panel);
		panel.add(btnNext);
		
		btnMainMenu = new JButton("Main Menu");
		btnMainMenu.setFont(new Font("Tahoma", Font.BOLD, 14));
		
		sl_panel.putConstraint(SpringLayout.WEST, btnMainMenu, 66, SpringLayout.WEST, panel);
		sl_panel.putConstraint(SpringLayout.SOUTH, btnMainMenu, -28, SpringLayout.SOUTH, panel);
		panel.add(btnMainMenu);
		
		setComboBox(new JComboBox());
		sl_panel.putConstraint(SpringLayout.NORTH, getComboBox(), -3, SpringLayout.NORTH, label_1);
		sl_panel.putConstraint(SpringLayout.WEST, getComboBox(), 97, SpringLayout.WEST, panel);
		sl_panel.putConstraint(SpringLayout.EAST, getComboBox(), -39, SpringLayout.WEST, label_1);
		panel.add(getComboBox());
		
		comboBox.addItemListener(new java.awt.event.ItemListener() {
			public void itemStateChanged(java.awt.event.ItemEvent e) {
				System.out.println("itemStateChanged()"); 
				lblNot.setVisible(false);
			
				}
			
		});
		
		
		label = new JLabel("select semester and course :");
		sl_panel.putConstraint(SpringLayout.WEST, label, 89, SpringLayout.WEST, panel);
		sl_panel.putConstraint(SpringLayout.SOUTH, label, -198, SpringLayout.NORTH, btnMainMenu);
		sl_panel.putConstraint(SpringLayout.EAST, label, -506, SpringLayout.EAST, panel);
		label.setFont(new Font("Tahoma", Font.BOLD, 13));
		panel.add(label);
		
		JLabel label_3 = new JLabel("You can view all information related to assignments of previous semesters");
		sl_panel.putConstraint(SpringLayout.SOUTH, label_3, -325, SpringLayout.SOUTH, panel);
		sl_panel.putConstraint(SpringLayout.NORTH, label, 42, SpringLayout.SOUTH, label_3);
		sl_panel.putConstraint(SpringLayout.NORTH, label_1, 79, SpringLayout.SOUTH, label_3);
		sl_panel.putConstraint(SpringLayout.WEST, label_3, 78, SpringLayout.WEST, panel);
		label_3.setFont(new Font("Tahoma", Font.BOLD, 15));
		panel.add(label_3);
		
		lblNot = new JLabel("Invalid selection");
		lblNot.setForeground(Color.RED);
		sl_panel.putConstraint(SpringLayout.WEST, lblNot, 168, SpringLayout.EAST, btnMainMenu);
		//lblNot.setEnabled(false);
		lblNot.setVisible(false);
		sl_panel.putConstraint(SpringLayout.NORTH, lblNot, 6, SpringLayout.SOUTH, btnNext);
		sl_panel.putConstraint(SpringLayout.EAST, lblNot, 37, SpringLayout.EAST, btnNext);
		lblNot.setIcon(new ImageIcon(PrevSemestersGUI.class.getResource("/javax/swing/plaf/metal/icons/ocean/error.png")));
		panel.add(lblNot);
		
	}
	public static JComboBox getComboBox() {
		return comboBox;
	}
	public static void setComboBox(JComboBox comboBox) {
		PrevSemestersGUI.comboBox = comboBox;
	}
}
